<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/event.css') ?>
<?php
$columns = array('info', 'place', 'date');
if (isset($this->columns)) {
    $columns = $this->columns;
}
?>
<table class="table table-hover table-striped">
    <tbody>
        <?php foreach ($this->rows as $row): ?>
            <tr>
                <?php if(in_array('info', $columns)): ?>
                <td class="col-info">
                    <a href="<?= $this->url(array('controller' => 'event', 'action' => 'show', 'id' => $row['event_code']), 'default', true) ?>">
                        <?= $row['info_name'] ?>
                    </a>
                </td>
                <?php endif ?>
                <?php if(in_array('place', $columns)): ?>
                <td class="col-place">
                    <a href="<?= $this->url(array('controller' => 'event-place', 'action' => 'show', 'id' => $row['place_code']), 'default', true) ?>">
                        <?= $row['place_name'] ?>
                    </a>
                </td>
                <?php endif ?>
                <?php if(in_array('date', $columns)): ?>
                <td class="col-date">
                    <?php
                    echo $row['start_date'];
                    if (!empty($row['start_time']))
                        echo ' &nbsp;' . substr($row['start_time'], 0, -3);
                    if (!empty($row['end_date'])) {
                        if ($row['start_date'] == $row['end_date'] && !empty($row['end_time'])) {
                            echo ' &nbsp;-&nbsp; ' . substr($row['end_time'], 0, -3);
                        } elseif ($row['start_date'] != $row['end_date']) {
                            echo ' &nbsp;-&nbsp; ' . $row['end_date'];
                            if (!empty($row['start_time']) && !empty($row['end_time'])) {
                                echo ' &nbsp;' . substr($row['end_time'], 0, -3);
                            }
                        }
                    } elseif (!empty($row['start_time']) && !empty($row['end_time'])) {
                        echo ' &nbsp;-&nbsp; ' . substr($row['end_time'], 0, -3);
                    }
                    ?>
                </td>
                <?php endif ?>
            </tr>
        <?php endforeach ?>
    </tbody>
</table>